<?php include_once __DIR__.'/../inc/userhead.html';?>
<?php include_once __DIR__.'/../inc/usermenu.html';?>
  <!--右面板-->
  <div class="main_panel">
    <!--头部-->
    <div class="panel_head">
      <ul class="title">
        <li><a href="javascript:;">我的订单</a></li>
      </ul>
      <div class="search">
        <form name="searchForm" action="" method="get">
		    <input name="goodsname" type="text" placeholder="请输入商品名称或者订单号" value="<?=$goodsname?>">
        	<select name='fahuostatus' class='order_sel'>
        	       <option value='' <?php if($fahuostatus == ''):?>selected<?php endif;?>>--商品状态--</option>
                   <option value='0' <?php if($fahuostatus == '0'):?>selected<?php endif;?>>未发货</option>
                   <option value='1' <?php if($fahuostatus == '1'):?>selected<?php endif;?>>已发货</option>
        	</select>
	        <div class="search_btn" onclick="document.searchForm.submit()">模糊查询</div>
		</form>
	  </div>
    </div>
    <!--头部-->
    <!--内容-->
    <div class="panel_list">
        <table class="layui-table">
            <colgroup>
              <col>
              <col>
              <col width=100>
              <col width=100>
              <col width=100>
              <col width=100>
            </colgroup>
            <thead>
              <tr>
                <th>商品名称</th>
                <th>订单编号</th>
                <th>单价</th>
                <th>数量</th>
                <th>交易状态</th>
                <th>发货状态</th>
                <th>操作</th>
              </tr>
            </thead>
            <tbody>
            <?php foreach($gooodslist as $v):?>
              <tr>
                <td><?=$v['title']?></td>
                <td><a href="/order/detail?order_no=<?=$v['order_no']?>"><?=$v['order_no']?></a></td>
                <td><?=$v['goods_price_price']?></td>
                <td><?=$v['nums']?></td>
                <td>
                    <?php if($v['refund_status'] != 0):?>
                        <?=c('type.refund_status')[$v['refund_status']]?>
                    <?php else:?>
                        <?=c('type.pay_status')[$v['pay_status']]?>
                    <?php endif;?>
                </td>
                <td><?=c('type.fahuo_status')[$v['fahuo_status']]?></td>
                <td>
                    <?php if($v['fahuo_status']==1):?>
                    <a href='javascript:;' onclick="goodsevaluate(<?=$v['id']?>)"><?=$v['sh_status']?'查看评价':'确认收货';?></a>
                    <a href="https://www.kuaidi100.com/chaxun?com=<?=$v["kd_code"]?>&nu=<?=$v["kd_no"]?>" target="_blank">
                        <span bianji="" class="head_r fr">查看物流</span>
                    </a>
                    <?php endif;?>
                    <?php if($v['pay_status']==1 && $v['fahuo_status']==0 && $v['refund_status'] == 0):?>
                        <a href='javascript:;' onclick="refundmoney(<?=$v['id']?>)">申请退款</a>
                    <?php endif;?>
                </td>
              </tr>
              <?php endforeach;?>
            </tbody>
        </table>

        <?php if($gooodslist):?>
        <!--分页-->
        <div class="plan_pager fr">
          <div class="pageing" id='page'>
          </div>
        </div>
        <!--分页-->
       <?php else:?>
           <p class="buyNull">还没有订单哦！，快去选购吧！</p>
       <?php endif;?>
	</div>
    </div>
    <!--内容-->
  </div>
  <!--右面板-->
</div>

<script>
    function goodsevaluate(id){
        layer.open({
            title: '评价',
            type: 2,
            area: ['50%', '400px'],
            content: '/user/goodsevaluate?id='+id
        });
    }

    function refundmoney(id){
        layer.confirm('确认要申请退款吗?', function(index) {
            $.ajax({
                url: "/order/refundmoney",
                method: "post",
                dataType: "json",
                data: { id: id },
                success: function(res) {
                    my.action(res);
                    layer.close(index);
                }
            });
        });
    }

    layui.use(['laypage'], function(){
        var laypage = layui.laypage;
        //总页数大于页码总数
        laypage.render({
          elem: 'page'
          ,count:<?=$page_count?>  //数据总数
          ,curr:<?=$page?>
          ,limit:10
          ,jump: function(obj,first){
            //首次不执行
            if(!first){
                var o = GetRequest();
                    o.page = obj.curr;
                    o.url  = '/user/collect';
                window.location.href = createUrl(o);
            }
          }
        });
    });
</script>
<?php include_once __DIR__.'/../inc/foot.html';?>
